/*
使用方式 引用该js就行 前提是type=file的name=file
<script type="text/javascript" src="${path}/skin/js/checkfile.js"></script>
如果特殊需要，在js中添加，例如单文件上传
if(checkFileSymbol(fileName)==false){//验证文件
    $("#file").val("");
     $("#showFileName"+node).html("");
    return false;
}
*/
function checkFileSymbol(fileval) {
    if(fileval){
        var fileType = fileval.substring(fileval.lastIndexOf(".")+1,fileval.length);//文件类型
        var fileName = fileval.substring(fileval.lastIndexOf("\\")+1,fileval.lastIndexOf("."));//文件名字
        var  symbolName = ["",".",",","/","\\", "'","\"", "　"," ",":","_","*","?","#","（","）","（）"];//文件名校验

        //如果验证什么文件，不可以上传，那么就得一个一个枚举，不能上传的文件，远远很多。
        var  symbolType = [
                            "bat","exe","com","ps1","msi","sys",
                            "sh","py","bin",
                            "sql","dll","flt","inl","php","hpp","chmod","js","css","asp","aspx","java","class","html","htm","vue","ttf","json","md"
                         ];//文件类型校验
        if(symbolType.indexOf(fileType)!=-1){//特殊文件
            parent.layer.msg("不支持的上传该文件类型");
            return false;
        }


        if(fileName){
            for(var i=0;i<fileName.length;i++){
                if(symbolName.indexOf(fileName[i])!=-1){//特殊文件名字
                    parent.layer.msg("文件名字不能含有特殊字符");
                    return false;
                }
            }
        }
    }
    return true;
}



$("body").on("input","[name='file'],[name='files']",function () {
    var fileName = $(this).val();
    if(checkFileSymbol(fileName)==false){//验证文件
        $(this).val("");
    }
});

